#ifndef SUPPLIERDIALOG_H
#define SUPPLIERDIALOG_H

#include <QDialog>

extern "C" {
#include "../backend/supplier.h" // Include the C struct definition
}

// 向前声明
class QLineEdit;

class SupplierDialog : public QDialog {
    Q_OBJECT

public:
    Supplier data; // Public member to store the resulting data
    QLineEdit *idEdit, *nameEdit, *contactEdit, *phoneEdit, *addressEdit;

    // 构造函数：父控件，可选的初始数据，ID 是否可编辑的标志
    SupplierDialog(QWidget* parent = nullptr, const Supplier* init = nullptr, bool idEditable = true);

    // 重写 accept 以验证和填充数据结构体
    void accept() override;

private slots:
    // 实时输入验证
    void validateInput();

private:
    // 设置输入验证器
    void setupValidators();
};

#endif // SUPPLIERDIALOG_H